package com.k8.common.compiler.javassistCompiler.bytecode;

import javassist.LoaderClassPath;
import javassist.NotFoundException;

import java.io.InputStream;
import java.net.URL;

public class CompilerLoaderClassPath extends LoaderClassPath {
    public CompilerLoaderClassPath() {
        super(CompilerLoaderClassPath.class.getClassLoader());
    }

    @Override
    public InputStream openClassfile(String classname) throws NotFoundException {
        if (!classname.startsWith("com.k8")
                && !classname.startsWith("grpc.health")
                && !classname.startsWith("com.google")) {
            return null;
        }
        return super.openClassfile(classname);
    }

    @Override
    public URL find(String classname) {
        if (!classname.startsWith("com.k8")) {
            return null;
        }
        return super.find(classname);
    }

}
